package com.stylesmile.socket.util;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * ip 工具类
 */
public class IpUtil {
    /**
     * 返回本地主机的自动检测名称。
     * Returns the local host's auto-detected name.
     *
     * @return the local host name 本地主机名
     */
    public static String detectLocalHostName() {
        try {
            return InetAddress.getLocalHost().getCanonicalHostName();
        } catch (UnknownHostException uhe) {
            return "localhost";
        }
    }
}
